package com.tj.collection.controller.admin.request;


import com.fqgj.common.api.ParamsObject;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.exception.common.ApiIllegalArgumentException;
import com.tj.collection.db.domain.Permission;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2016/11/22
 * Time: 下午4:09
 */
public class AddOperationVo extends ParamsObject {
    private String name;
    private String key;
    private Long menuId;

    public String getName() {
        return name;
    }

    public AddOperationVo setName(String name) {
        this.name = name;
        return this;
    }

    public String getKey() {
        return key;
    }

    public AddOperationVo setKey(String key) {
        this.key = key;
        return this;
    }

    public Long getMenuId() {
        return menuId;
    }

    public AddOperationVo setMenuId(Long menuId) {
        this.menuId = menuId;
        return this;
    }

    @Override
    public void validate() {
        if (StringUtils.isEmpty(key) || key == null) {
            throw new ApiIllegalArgumentException("参数错误");
        }
    }


    public Permission trans2Permission() {
        return new Permission().setMenuId(menuId).setPermission(key).setName(name);
    }


}
